package com.travel.group.service.Impl;

import com.baomidou.mybatisplus.core.conditions.Wrapper;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.github.pagehelper.PageHelper;
import com.travel.group.dao.GroupMapper;
import com.travel.group.dao.UserMapper;
import com.travel.group.entity.Group;
import com.travel.group.entity.Users;
import com.travel.group.service.GroupService;
import com.travel.group.service.UserService;
import org.apache.shiro.SecurityUtils;
import org.apache.shiro.authc.UsernamePasswordToken;
import org.apache.shiro.subject.Subject;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class GroupServiceImpl extends ServiceImpl<GroupMapper, Group> implements GroupService {

    @Override
    public List<Group> getByGroupIds(List<Integer> ids) {
        return baseMapper.selectBatchIds(ids);
    }

    @Override
    public List<Group> getAllGroupInfo(Integer page, Integer limit) {
        PageHelper.startPage(page, limit);
        List<Group> groups = baseMapper.selectList(null);
        return groups;
    }

    @Override
    public List<Group> getAllGroupInfoPlus(Integer page, Integer limit, String name) {
        PageHelper.startPage(page, limit);
        List<Group> groups = baseMapper.selectList(new QueryWrapper<Group>().like("name",name));
        return groups;
    }

    @Override
    public List<Group> getAllMyGroupInfo(Integer page, Integer limit) {
        PageHelper.startPage(page, limit);
        List<Group> groups = baseMapper.selectList(null);
        return groups;
    }

    @Override
    public Integer countData() {
        List<Group> groups = baseMapper.selectList(null);
        return groups.size();
    }
}
